<%@ page contentType="text/html;charset=UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<c:set var="ctx" value="${pageContext.request.contextPath}"/>
<!DOCTYPE html>
<html lang="zh-CN">
  <head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <%@ include file="/common/ssb/include/common-base.jsp"%>
  <title>提现设置</title>
  <!-- Tell the browser to be responsive to screen width -->
  <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
</head>

<!-- Part 一、 以下是body主体内容的模块区域 -->
<body class="hold-transition ${sysColor} sidebar-mini">
<div class="wrapper">

  <!-- top start -->
  <%@include file="/common/ssb/top.jsp" %>
  <!-- top end -->
  <!-- left start -->
  <%@include file="/common/ssb/left.jsp" %>
  <!-- left end-->

  <div class="content-wrapper">
    <!-- Main start -->
	<section class="content">
	  			<div id="div_hidden_content" class="hidden" style="display:none;">
	  			    <input name="templateType" type="hidden" value="add"/>
                    <div id="hidden_common_final">
                        <!-- temp="hidden_common_final" start -->
										<input name="mainObjName" type="hidden" value="sysAppConfig">
										<input name="mainObjPrimaryKey" type="hidden" value="infoId">
										<input name="objNameAll" type="hidden" value="sysAppConfig">
				<!-- temp="hidden_common_final" end -->
                     </div>
	  			</div>
      <div class="row">
        <div class="col-lg-12">
        
          <div class="box box-info">
	          <div class="box-header with-border">
                 <h3 class="box-title"><i class="fa fa-edit"></i>提现设置</h3>
              </div>
            <div class="box-body">

            	<form class="form-horizontal addFormBody" id="addForm1" action="javascript:void(0)">
					<input type="hidden" class="formToken" id="addForm1_formToken" name="formToken" />
					<!-- temp="addForm1_hidden" start -->
					<div id="addForm1_hidden">
                        <input type="hidden" name="pageName" value="sys-app-config"/>
                        <input type="hidden" name="formName" value="editForm"/>
                        <input type="hidden" name="sysAppConfig.w_sysName" value="ssb" data-name="sysAppConfig.sysName"
                               class="sysAppConfig_sysName clean">
                        <input type="hidden" name="sysAppConfig.w_typeCode" value="yjpz" data-name="sysAppConfig.typeCode"
                               class="sysAppConfig_typeCode clean">
                        <input type="hidden" name="sysAppConfig.w_appKey" value="yjpz_out_max" data-name="sysAppConfig.appKey"
                               class="sysAppConfig_appKey clean">
                        <input name="sysAppConfig.typeName" class="form-control clean" type="hidden"
                               data-temp-obj="sysAppConfig.typeName" data-name="sysAppConfig.typeName">
                        <input name="sysAppConfig.status" class="form-control clean" type="hidden"
                               data-temp-obj="sysAppConfig.status" data-name="sysAppConfig.status">
                        <input name="sysAppConfig.ifEdit" class="form-control clean" type="hidden"
                               data-temp-obj="sysAppConfig.ifEdit" data-name="sysAppConfig.ifEdit">
                        <input name="sysAppConfig.appRemark" class="form-control clean" type="hidden"
                               data-temp-obj="sysAppConfig.appRemark" data-name="sysAppConfig.appRemark">
                        <input name="sysAppConfig.appName" class="form-control clean" type="hidden"
                               data-temp-obj="sysAppConfig.appName" data-name="sysAppConfig.appName">
                    </div>
					<!-- temp="addForm1_hidden" end -->
					
					<div class="panel">
						<div class="panel-body">
						
							<!-- temp="addForm1_content_1" start -->
											<div id="addForm1_content_1" data-temp-code="true" data-temp-type="addForm" data-temp-form-id="addForm_content_1">

                                                <table class="table table-bordered bordercolor">
                                                    <tbody>
                                                    <tr>
                                                        <td class="active" align="right"><label
                                                                class="form-control-static">提现上限设置(元)：</label></td>
                                                        <td>
                                                            <div class="form-group"><input name="sysAppConfig.appValue"
                                                                                           data-name="sysAppConfig.appValue"
                                                                                           class="form-control clean"
                                                                                           maxlength="30"
                                                                                           data-temp-obj="sysAppConfig.appValue" data-bv-regexp="true"
                                                                                           data-bv-regexp-regexp="^\d+$|^\d*\.\d+$"
                                                                                           data-bv-regexp-message="只能输入数字！"
                                                                                           placeholder="必填项"
                                                                                           data-bv-notempty="true"
                                                                                           data-bv-notempty-message="不能为空">
                                                            </div>
                                                        </td>
                                                        <td class="active" align="right"><label
                                                                class="form-control-static">提现下限设置(元)：</label></td>
                                                        <td>
                                                            <div class="form-group"><input name="sysAppConfig.appLowValue"
                                                                                           data-name="sysAppConfig.appLowValue"
                                                                                           class="form-control clean"
                                                                                           maxlength="30"
                                                                                           data-temp-obj="sysAppConfig.appLowValue" data-bv-regexp="true"
                                                                                           data-bv-regexp-regexp="^\d+$|^\d*\.\d+$"
                                                                                           data-bv-regexp-message="只能输入数字！"
                                                                                           placeholder="必填项"
                                                                                           data-bv-notempty="true"
                                                                                           data-bv-notempty-message="不能为空">
                                                            </div>
                                                        </td>
                                                    </tr>
                                                    </tbody>
                                                </table>
                                            </div>
				<!-- temp="addForm1_content_1" end -->
							
						</div>
					</div>
            	</form>
            </div>
            
             <div class="box-footer text-center">
			       <button type="button" class="btn btn-success" onclick="submitForm1('addForm1','');" data-temp-event="addForm1_hidden"><i class="fa fa-save"></i> 提交保存 </button> 
			       <button type="button" class="btn btn-warning" onclick="mytools.cleanData('.addFormBody');">重置 </button>
			 </div>
	     </div>
           
       
        </div>
      </div>
  

<!-- Part 二、 以下是js模块区域 -->
<script>
var clickMenu= 'sys-fund-limit';
/**
 * 初始化数据字典，id传入#id 返回值Map用法：dictListMap["userType"][rows[i].userType]
 */
//var dictListMap = DictUtil.initDictAndDymic();
 
$(function () {
    getTabData();
    var formId = "#addForm1";
    setValidate(formId);//定义add表单验证属性
    mytools.cleanValidate(formId);//清空上次校验规则提示
});
 
//注入日历框样式
var dateObject = $('.datepicker').datepicker( {
	language : 'zh-CN',
	//inline: true,
	todayBtn : "linked",
	format : "yyyy-mm-dd",
	autoclose: true
}).on('hide',function(e) {
	//bootstrap-datepicker与bootstrapValidator同时使用时选择日期后无法正常触发校验的解决方法
	//当日期选择框关闭时，执行刷新校验。
	var fieldName = $(this).attr("name");//获取当前元素name
	var formId = $(this).parents("form").eq(0).attr("id");//获取当前元素所在父层级中的就近的formId
    $("#"+formId).data('bootstrapValidator').updateStatus(fieldName,'NOT_VALIDATED',null).validateField(fieldName);
});

//查询后台配数据
function getTabData() {
    var index_load = layer.load(1, {shade: false});
    $.ajax({
        type:"get",
        url:common_info_url,dataType:"json",
        data: {'pageName':'sys-app-config','formName':'searchForm','sysAppConfig.w_sysName':sysName,'sysAppConfig.w_typeCode':'yjpz','sysAppConfig.w_appKey':'yjpz_out_max'},
        success: function(myData){
            layer.close(index_load);
          //  console.log(myData);
            if (myData) {
                var obj = myData["sysAppConfig"];
                var vobj="sysAppConfig";
                for(x in obj){
                    key = vobj+"."+x;
                    value = obj[x]+'';
                    if(strUtil.isNull(value)){
                        value = strUtil.doNull(value, "");
                    }
                    var txtVal = value;
                    $("input[data-name='"+key+"']").val(txtVal);
                }
            }
        }
    });
}

//提交表单数据
function submitForm1(formId,tabId){
    var validate = $('#'+formId).data('bootstrapValidator').validate();
    if(!validate.isValid()){ //如果校验不通过就返回
        return;
    }
	var index_submit = layer.confirm('您确定要保存信息吗？', {btn: ['Yes','No'],closeBtn: 0,offset: '220px'}
	, function(){
		var result = submitForm(formId,tabId);
		if(result){
      		layer.alert("操作成功！");
            getTabData();
            loadCache();
      		setToken();
	  	}
	});
 }
//提交表单数据
function submitForm(formId,tabId){
	var result;
	var index_load = layer.load(1, {shade: false});
	$.ajax({
	    type:'post',
	    url:common_submit_url,
	    data:$("#"+formId).serialize(),
	    async:false,
	    dataType:'json',
	    success: function(myData){ 
	     console.log(myData);
	        if(myData.flag=="T"){
	        	result = myData;
	    	}else{
	    		setToken();
	     		layer.alert(myData.msg);
	    	}
	        layer.close(index_load);
	  	},
	     error: function (e) {
		     layer.close(index_load);
     	} 
	});	
	return result;
}

function loadCache(){
    var index_load = layer.msg("数据同步进行中。。。",{time:false});
    $.ajax({
        type:'post',
        url: common_cache_url+"init",
        data:{"pageName":"sys-app-config-list","formName":"initiCacheForm","sysAppConfig.w_sysName":sysName},
        dataType:'json',
        success: function(myData){
            console.log("sysAppConfig.initiCacheForm",myData);
            layer.close(index_load);
        }
    });
}

//设置token
function setToken(){
	$.ajax({
	    type:'get',
	    url:'${ctx}/sendPage/token?token=true',
	    dataType:'text',
	    success: function(myData){
	    	console.log(myData);
			$('.formToken').val(myData);
	  	}
	});	
}

/**** Part 三、以下是自定义新增方法  ****/
//1.定义校验规则-定义
function setValidate(id){
	$(id).each(function(){
		$(this).bootstrapValidator({
		    feedbackIcons: {
		        valid: 'glyphicon glyphicon-ok',
		        invalid: 'glyphicon glyphicon-remove',
		        validating: 'glyphicon glyphicon-refresh'
		    },/** 以下需要结合实际业务清空补充个表单元素的验证规则 **/
		 	fields:{
		 		/** 可自定义新增验证规则
		    	"uctUser.userEname":{
		    		 validators: {
		    			 regexp: {
		    				 regexp: /^[0-9]+$/,
		                      message: '只能是数字'
		                  }
		              }
		    	}
		    	**/
			}
		});
	});
}


</script>
</section>
<!-- Main end -->   
</div>
<!-- foot start -->
<%@include file="/common/ssb/foot.jsp" %>
<!-- foot start -->
</div>
<!-- /.content-wrapper -->
</body>
</html>



